<html>
<head><meta charset="utf-8"><title>Stabilizing array_chunks/slice_as_chunks · t-libs · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/index.html">t-libs</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Stabilizing.20array_chunks.2Fslice_as_chunks.html">Stabilizing array_chunks/slice_as_chunks</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="227728632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Stabilizing%20array_chunks/slice_as_chunks/near/227728632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Teddy Katz <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Stabilizing.20array_chunks.2Fslice_as_chunks.html#227728632">(Feb 25 2021 at 07:31)</a>:</h4>
<p>Issues: <a href="https://github.com/rust-lang/rust/issues/76354">https://github.com/rust-lang/rust/issues/76354</a> and <a href="https://github.com/rust-lang/rust/issues/76354">https://github.com/rust-lang/rust/issues/76354</a></p>
<p>Hi folks,</p>
<p>I wanted to check what the current blockers are, if any, for stabilizing <code>array_chunks</code> and <code>slice_as_chunks</code>. The tl;dr is that <code>std::slice::array_chunks</code> iterates over const-length array chunks of a slice <code>&amp;[T]</code>, and <code>std::slice::as_chunks</code> returns a <code>&amp;[[T; N]]</code> (i.e. the same thing, except it gives a slice directly rather than iterating over it). Both functions have reverse and <code>mut</code>-slice variants.</p>
<p>AFAICT, the outstanding questions are:</p>
<ul>
<li>How to expose <code>&amp;[T] -&gt; &amp;[[T; N]]</code>? This is a useful operation to be able to do safely, but technically we could add a field to access the slice to the iterator returned from <code>array_chunks</code>, as an alternative to having separate <code>as_chunks</code>. Not clear that either option is drastically better; might just be a "pick one based on API design taste and go with it" decision.</li>
<li>What to do if the supplied chunk length is 0? Currently this is a runtime panic. Ideally this would be a compile error, but this seems like it would require waiting for full const generics rather than stabilizing with min const generics. Options seem to include (a) leaving it as a runtime panic forever, (b) waiting until <code>const_evaluatable_checked</code> to ship this, or (c) documenting that it will be changed it to a compile error later (maybe unacceptable for compatibility).</li>
</ul>
<p>My personal motivation for wanting to stabilize this sooner is that I think it's unfortunate that converting <code>&amp;[T] -&gt; &amp;[[T; N]]</code> currently requires unsafe code.</p>



<a name="227801096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Stabilizing%20array_chunks/slice_as_chunks/near/227801096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Stabilizing.20array_chunks.2Fslice_as_chunks.html#227801096">(Feb 25 2021 at 17:04)</a>:</h4>
<p>.as_chunks().iter() seems a reasonable thing to type, if we want to keep the number of methods minimal</p>



<a name="227802662"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Stabilizing%20array_chunks/slice_as_chunks/near/227802662" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Stabilizing.20array_chunks.2Fslice_as_chunks.html#227802662">(Feb 25 2021 at 17:14)</a>:</h4>
<p><code>.as_chunks()</code> is currently returning a tuple <code>(chunks, remainder)</code>, so that would be <code>.as_chunks().0.iter()</code></p>



<a name="227806181"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Stabilizing%20array_chunks/slice_as_chunks/near/227806181" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Giacomo Stevanato <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Stabilizing.20array_chunks.2Fslice_as_chunks.html#227806181">(Feb 25 2021 at 17:37)</a>:</h4>
<p>What about <code>.array_chunks().as_slice()</code> and <code>.array_chunks().remainder()</code> instead of <code>.as_chunks()</code>?</p>



<a name="227818997"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Stabilizing%20array_chunks/slice_as_chunks/near/227818997" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Teddy Katz <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Stabilizing.20array_chunks.2Fslice_as_chunks.html#227818997">(Feb 25 2021 at 19:03)</a>:</h4>
<p>For the <code>mut</code> versions, would it be <code>.array_chunks_mut().as_mut_slice()</code>? If so, would <code>as_slice</code> on an <code>ArrayChunksMut</code> also be available and return a shared slice? Or <code>as_slice</code> just return a slice of the corresponding type for all variants?</p>



<a name="227821414"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Stabilizing%20array_chunks/slice_as_chunks/near/227821414" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Stabilizing.20array_chunks.2Fslice_as_chunks.html#227821414">(Feb 25 2021 at 19:18)</a>:</h4>
<p>The <code>mut</code> versions are important here -- <code>.array_chunks_mut()</code> would need something like <code>.as_slice_and_remainder()</code> if you wanted to be able to get both slices at once, at which point it's back to being essentially <code>.as_chunks_mut()</code>.</p>



<a name="227821491"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Stabilizing%20array_chunks/slice_as_chunks/near/227821491" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Stabilizing.20array_chunks.2Fslice_as_chunks.html#227821491">(Feb 25 2021 at 19:19)</a>:</h4>
<p><code>vec::IntoIter</code> has both <code>as_slice()</code> and <code>as_mut_slice()</code><br>
<code>slice::IterMut</code> has <code>as_slice(&amp;self) -&gt; &amp;[T]</code> and <code>into_slice(self) -&gt; &amp;mut [T]</code></p>



<a name="227821623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Stabilizing%20array_chunks/slice_as_chunks/near/227821623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Stabilizing.20array_chunks.2Fslice_as_chunks.html#227821623">(Feb 25 2021 at 19:20)</a>:</h4>
<p>but <code>slice::IterMut</code> could reasonably have <code>as_mut_slice()</code> too, reborrowing</p>



<a name="227821716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Stabilizing%20array_chunks/slice_as_chunks/near/227821716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Stabilizing.20array_chunks.2Fslice_as_chunks.html#227821716">(Feb 25 2021 at 19:20)</a>:</h4>
<p>I mean the borrow-check implications -- if I call <code>.as_mut_slice()</code> on the iterator, it "locks"s it so I can't <em>also</em> call <code>.remainder()</code>.  Thus the need for the version that returns the tuple with both mutable slices.</p>



<a name="227821733"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Stabilizing%20array_chunks/slice_as_chunks/near/227821733" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Stabilizing.20array_chunks.2Fslice_as_chunks.html#227821733">(Feb 25 2021 at 19:20)</a>:</h4>
<p>yes, true</p>



<a name="227822004"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Stabilizing%20array_chunks/slice_as_chunks/near/227822004" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Stabilizing.20array_chunks.2Fslice_as_chunks.html#227822004">(Feb 25 2021 at 19:22)</a>:</h4>
<blockquote>
<p>Or <code>as_slice</code> just return a slice of the corresponding type for all variants?</p>
</blockquote>
<p>I was more directly responding to this -- the precedent is that <code>as_slice</code> is always shared</p>



<a name="227822377"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Stabilizing%20array_chunks/slice_as_chunks/near/227822377" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Stabilizing.20array_chunks.2Fslice_as_chunks.html#227822377">(Feb 25 2021 at 19:24)</a>:</h4>
<p>I think the important conceptual model question here is what one is normally expected to do with the remainder.</p>
<ul>
<li>
<p>If it's normal to silently ignore the remainder, then the <code>.array_chunks()</code> iterator is great.</p>
</li>
<li>
<p>If one should normally at least be looking at the remainder -- perhaps just as <code>assert!(remainder.is_empty())</code> or <code>if let (chunks, &amp;[]) = slice.as_chunks() {</code> -- then I think the <code>.as_chunks()</code> is better because it's more likely to not be forgotten.  (Or at least it'd be more noticeably ignored, via <code>let (chunks, _) =</code> or <code>.0</code>.)</p>
</li>
</ul>



<a name="227822577"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Stabilizing%20array_chunks/slice_as_chunks/near/227822577" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Stabilizing.20array_chunks.2Fslice_as_chunks.html#227822577">(Feb 25 2021 at 19:25)</a>:</h4>
<p><code>chunks_exact</code> also sets a precedent here</p>



<a name="227822679"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Stabilizing%20array_chunks/slice_as_chunks/near/227822679" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Stabilizing.20array_chunks.2Fslice_as_chunks.html#227822679">(Feb 25 2021 at 19:26)</a>:</h4>
<p>in that a possibly-forgettable remainder is a thing</p>



<a name="227823983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Stabilizing%20array_chunks/slice_as_chunks/near/227823983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Stabilizing.20array_chunks.2Fslice_as_chunks.html#227823983">(Feb 25 2021 at 19:33)</a>:</h4>
<p>It might also set a precedent that it should have <code>exact</code> in the name to mark that, though.  Dunno.</p>



<a name="227830258"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Stabilizing%20array_chunks/slice_as_chunks/near/227830258" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Stabilizing.20array_chunks.2Fslice_as_chunks.html#227830258">(Feb 25 2021 at 20:08)</a>:</h4>
<p>yeah we should go as close as possible to existing slice content</p>



<a name="227830306"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Stabilizing%20array_chunks/slice_as_chunks/near/227830306" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Stabilizing.20array_chunks.2Fslice_as_chunks.html#227830306">(Feb 25 2021 at 20:09)</a>:</h4>
<p>so chunks for "maybe has a remainder", chunks_exact for "you are asserting no remainder here"</p>



<a name="227830700"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Stabilizing%20array_chunks/slice_as_chunks/near/227830700" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Teddy Katz <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Stabilizing.20array_chunks.2Fslice_as_chunks.html#227830700">(Feb 25 2021 at 20:11)</a>:</h4>
<p>In my experience with <code>chunks_exact</code>, I often want to assert that the remainder is empty, but this is a bit inconvenient (e.g. requires assigning to a variable) so I sometimes end up ignoring the remainder instead. That's not ideal, but it's unclear what would be the best way to deal with it here, aside from having a separate function that panics if there's a remainder.</p>
<p>Aside from that, it seems weird to only be able to access one of the {slice, remainder} mutably. This is just an intuitive reaction based on thinking that accessing both parts mutably is a plausibly useful primitive, with no "good" (soundness-related) reason to disallow it. I don't have an actual use case in mind.</p>
<p>I suppose if we did disallow accessing both parts mutably, someone could work around it by doing some math and calling <code>split_at_mut</code> before <code>array_chunks</code>. But that seems like it's not ideal for ergonomics.</p>



<a name="227830964"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Stabilizing%20array_chunks/slice_as_chunks/near/227830964" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Stabilizing.20array_chunks.2Fslice_as_chunks.html#227830964">(Feb 25 2021 at 20:13)</a>:</h4>
<p>oh oops, chunks_exact can have a remainder, it's just not in the main iterator. i guess we can't follow that so well here.</p>



<a name="227843800"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Stabilizing%20array_chunks/slice_as_chunks/near/227843800" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Stabilizing.20array_chunks.2Fslice_as_chunks.html#227843800">(Feb 25 2021 at 21:41)</a>:</h4>
<p><span class="user-mention silent" data-user-id="392468">Teddy Katz</span> <a href="#narrow/stream/219381-t-libs/topic/Stabilizing.20array_chunks.2Fslice_as_chunks/near/227830700">said</a>:</p>
<blockquote>
<p>I suppose if we did disallow accessing both parts mutably, someone could work around it by doing some math and calling <code>split_at_mut</code> before <code>array_chunks</code>. But that seems like it's not ideal for ergonomics.</p>
</blockquote>
<p>That math and <code>split_at_mut</code> is basically what <code>as_chunks_mut</code> is doing <span aria-label="upside down" class="emoji emoji-1f643" role="img" title="upside down">:upside_down:</span></p>



<a name="227844133"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Stabilizing%20array_chunks/slice_as_chunks/near/227844133" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Stabilizing.20array_chunks.2Fslice_as_chunks.html#227844133">(Feb 25 2021 at 21:43)</a>:</h4>
<p>The "I often expect the remainder to be empty" conversation does make the think about something like <code>-&gt; Result&lt;&amp;[[T; N]], (&amp;[[T; N]], &amp;[T])&gt;</code> so it can be <code>.unwrap()</code>ed, but that return type would be pretty awkward to use when you're ok with there sometimes being a remainder.</p>



<a name="227845546"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Stabilizing%20array_chunks/slice_as_chunks/near/227845546" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Stabilizing.20array_chunks.2Fslice_as_chunks.html#227845546">(Feb 25 2021 at 21:53)</a>:</h4>
<p>yeah that sounds annoying to use...</p>



<a name="227848029"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Stabilizing%20array_chunks/slice_as_chunks/near/227848029" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> The 8472 <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Stabilizing.20array_chunks.2Fslice_as_chunks.html#227848029">(Feb 25 2021 at 22:11)</a>:</h4>
<p>don't slice patterns already solve matching on the returned tuple if you want to distinguish the exact case</p>



<a name="227854216"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Stabilizing%20array_chunks/slice_as_chunks/near/227854216" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Teddy Katz <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Stabilizing.20array_chunks.2Fslice_as_chunks.html#227854216">(Feb 25 2021 at 23:01)</a>:</h4>
<p>I suppose you can do something like this:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">process_chunks</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">(</span><span class="n">chunks</span>: <span class="kp">&amp;</span><span class="nc">mut</span><span class="w"> </span><span class="p">[[</span><span class="n">T</span><span class="p">;</span><span class="w"> </span><span class="n">N</span><span class="p">]])</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="cm">/* ... */</span><span class="w"> </span><span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">process_data</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">(</span><span class="n">data</span>: <span class="kp">&amp;</span><span class="nc">mut</span><span class="w"> </span><span class="n">T</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="c1">// before (no assertion):</span>
<span class="w">  </span><span class="n">process_chunks</span><span class="p">(</span><span class="n">data</span><span class="p">.</span><span class="n">as_chunks_mut</span><span class="p">().</span><span class="mi">0</span><span class="p">)</span><span class="w"></span>

<span class="w">  </span><span class="c1">// after (with assertion):</span>
<span class="w">  </span><span class="n">process_chunks</span><span class="p">(</span><span class="k">match</span><span class="w"> </span><span class="n">data</span><span class="p">.</span><span class="n">as_chunks_mut</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="p">(</span><span class="n">chunks</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="p">[])</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="n">chunks</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">_</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="fm">panic!</span><span class="p">(</span><span class="s">"unexpected remainder"</span><span class="p">),</span><span class="w"></span>
<span class="w">  </span><span class="p">})</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="227855520"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Stabilizing%20array_chunks/slice_as_chunks/near/227855520" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Stabilizing.20array_chunks.2Fslice_as_chunks.html#227855520">(Feb 25 2021 at 23:12)</a>:</h4>
<p>well that supposes that as_chunks_mut doesn't keep the borrow going once it's done</p>



<a name="228030681"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Stabilizing%20array_chunks/slice_as_chunks/near/228030681" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Teddy Katz <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Stabilizing.20array_chunks.2Fslice_as_chunks.html#228030681">(Feb 27 2021 at 04:01)</a>:</h4>
<p>So to centralize the discussion back on <code>array_chunks</code>/<code>slice_as_chunks</code> (let me know if anyone disagrees with the following summary, but this is my take so far):</p>
<ul>
<li>It seems like it might not be workable to get rid of <code>as_chunks_mut</code>, because this would prevent simultaneously accessing the slice and the remainder, even when no soundness issue exists when doing so. IMO, this is different from <code>chunks_exact_mut</code> (which has <code>into_remainder</code>) since <code>array_chunks_mut</code> exposes a slice rather than an iterator -- iterators are more likely to only be consumed once , which makes sharing less of a problem with <code>chunks_exact_mut</code>.</li>
<li>We could get rid of <code>array_chunks</code> in favor of <code>slice_as_chunks().0.iter()</code>. Alternatively, we could keep both.</li>
<li>Some discussion might still be needed on whether it's tenable to stabilize these before <code>const_evaluatable_checked</code>.</li>
</ul>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>